package com.thoughtworks;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class AnswerReader {

    public static List<String> getAnswer() {
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new FileReader(".\\src\\main\\resources\\answer.txt"));
            String answer = reader.readLine();
            return Helper.convert2ArrayList(answer);
        } catch (Exception e) {
            System.out.println("As answer.txt does not exist, now create random answer!");
            List<String> newAnswer = Helper.createRandomAnswer();
            System.out.println(Helper.convert2String(newAnswer));
            return newAnswer;
        } finally {
            try {
                if(null!=reader){
                    reader.close();
                }
            } catch (IOException ee) {
                ee.printStackTrace();
            }
        }
    }
}
